package test.test02.MyThread;

public class MyInterrupt01 {
    private static class MyRunnable implements Runnable{
        public volatile boolean isQuit = false;
        @Override
        public void run(){
            System.out.println("线程开始");
            while(!isQuit){
                System.out.println("线程中断");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("线程中断结束");
        }
    }
    public static void main(String[] args) throws InterruptedException {
        MyRunnable r1 = new MyRunnable();
        Thread t1 = new Thread(r1);
        t1.start();
        Thread.sleep(10*1000);
        r1.isQuit = true;
    }
    
}
